package java_class_work.week08.internet.upimage;

import java.io.*;
import java.net.Socket;

/**
 * @Author Tiam
 * @Date 2022/11/1 15:03
 * @Description:
 */
public class TcpClient {
    public static void main(String[] args) {
        try {
            Socket socket = new Socket("127.0.0.1", 8888);
            FileInputStream fileInputStream = new FileInputStream(new File(".\\src\\java_class_work\\iotest\\课程表.png"));
            OutputStream out = socket.getOutputStream();
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
// ***************************************************************************************
            int len = 0;
            byte[] bytes = new byte[1024];
            while ((len = fileInputStream.read(bytes)) != -1) {
                out.write(bytes, 0, len);
            }
            // 关闭发送
            socket.shutdownOutput();
            String s = in.readLine();
            System.out.println(s);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
